package com.itheima.service.Impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.POJO.Ill;
import com.itheima.POJO.Sport;
import com.itheima.dao.IllMapper;
import com.itheima.entity.PageResult;
import com.itheima.service.IllService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

@Service(interfaceClass = IllService.class)
@Transactional
public class IllServiceImpl implements IllService {

    @Autowired
    private IllMapper illDao;

    //分页查询
    public PageResult pagingQuery(Integer currentPage, Integer pageSize, String queryString) {

        PageHelper.startPage(currentPage, pageSize);
        Page<Ill> sportPage = illDao.findPage(queryString);

        PageResult pageResult = new PageResult(sportPage.getTotal(), sportPage.getResult());

        return pageResult;
    }

    //添加
    public void add(Ill ill) {
        illDao.add(ill);
    }

    //编辑窗口回显数据
    public Ill findSportById(Integer id) {
        return illDao.findSportById(id);
    }

    //编辑
    public void edit(Ill ill) {
        illDao.edit(ill);
    }

    //删除
    public void deleteById(Integer id) {
        illDao.deleteById(id);
    }


}
